#include <cstdio>
#include <cstring>

void InverseStr(char[]);

int main()
{
    int num;
    while (scanf("%d", &num) != EOF) {
        char ans[10];
        int pos = 0;
        do {
            ans[pos++] = num % 8 + '0';
            num /= 8;
        } while (num != 0);
        ans[pos] = '\0';
        InverseStr(ans);
        printf("%s\n", ans);
    }
}

void InverseStr(char num[])
{
    int low = 0, high = strlen(num) - 1, temp;
    for (; low < high; low++, high--) {
        temp = num[low];
        num[low] = num[high];
        num[high] = temp;
    }
}